<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>ECSHOP 管理中心 - 商品分类</title>
  <meta name="robots" content="noindex, nofollow">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <css file="__PUBLIC__/Admin/css/general.css" />
  <css file="__PUBLIC__/Admin/css/main.css" />
  <script type="text/javascript" src="__PUBLIC__/Admin/js/transport.js"></script>
  <script type="text/javascript" src="__PUBLIC__/Admin/js/common.js"></script>
</head>
<body>

  <h1>
    <span class="action-span">
      <a href="{:U('Category/addCate')}">添加分类</a>
    </span>
    <span class="action-span1">
      <a href="">MYSHOP 管理中心</a>
    </span>
    <span id="search_id" class="action-span1">- 商品分类</span>
    <div style="clear:both"></div>
  </h1>

  <script type="text/javascript" src="__PUBLIC__/Admin/js/utils.js"></script>
  <script type="text/javascript" src="__PUBLIC__/Admin/js/listtable.js"></script>

  <form method="post" action="" name="listForm">
    <div class="list-div" id="listDiv">

      <table width="100%" cellspacing="1" cellpadding="2" id="list-table">
        <tr>
          <th>分类名称</th>
          <!-- <th>商品数量</th>
        -->
        <th>所属类型</th>
        <th>导航栏</th>
        <th>是否显示</th>
        <th>操作</th>
      </tr>
      <foreach name='cate' item='v'>
        <tr align="center" class="{$v.lv}" id="{$v.lv}_{$v.id}">
          <td align="left" class="first-cell" >
            <img src="__PUBLIC__/Admin/images/menu_minus.gif" id="icon_{$v.lv}_{$v.id}" width="9" height="9" border="0" style="margin-left:{$v.lv}em" onclick="rowClicked(this)" />
            <span>
              <a href="">{$v.name}</a>
            </span>
          </td>
          <!-- <td width="10%">0</td>
        -->
        <td width="10%">
          <span>{$v.tid}</span>
        </td>
        <td width="10%">
          <img src="__PUBLIC__/Admin/images/yes.gif" />
        </td>
        <td width="10%">
          <img src="__PUBLIC__/Admin/images/yes.gif" />
        </td>
        <td width="44%" align="center">
          <a href="{:U('addCate', array('pid' =>$v['id']))}">添加子分类</a>
          |
          <a href="{:U('editCate', array('id' =>$v['id']))}">编辑</a>
          |
          <a href="javascript:;" onclick="listTable.remove(1, '您确认要删除这条记录吗?')" title="删除">删除</a>
        </td>
      </tr>
    </foreach>
    <!-- <tr align="center" class="1" id="1_2">
    <td align="left" class="first-cell" >
      <img src="__PUBLIC__/Admin/images/menu_minus.gif" id="icon_1_2" width="9" height="9" border="0" style="margin-left:1em" onclick="rowClicked(this)" />
      <span>
        <a href="goods.php?act=list&cat_id=2">衬衫</a>
      </span>
    </td>
    <td width="10%">0</td>
    <td width="10%">
      <span onclick="listTable.edit(this, 'edit_measure_unit', 2)">件</span>
    </td>
    <td width="10%">
      <img src="__PUBLIC__/Admin/images/no.gif" onclick="listTable.toggle(this, 'toggle_show_in_nav', 2)" />
    </td>
    <td width="10%">
      <img src="__PUBLIC__/Admin/images/yes.gif" onclick="listTable.toggle(this, 'toggle_is_show', 2)" />
    </td>
    <td width="24%" align="center">
      <a href="category.php?act=move&cat_id=2">转移商品</a>
      |
      <a href="category.php?act=edit&amp;cat_id=2">编辑</a>
      |
      <a href="javascript:;" onclick="listTable.remove(2, '您确认要删除这条记录吗?')" title="移除">移除</a>
    </td>
  </tr>
  -->
</table>
</div>
</form>

<script language="JavaScript">
<!--

var imgPlus = new Image();
    imgPlus.src = "__PUBLIC__/Admin/images/menu_plus.gif";

/**
 * 折叠分类列表
 */
function rowClicked(obj)
{
  // 当前图像
  img = obj;
  // 取得上二级tr>td>img对象
  obj = obj.parentNode.parentNode;
  // 整个分类列表表格
  var tbl = document.getElementById("list-table");
  // 当前分类级别
  var lvl = parseInt(obj.className);
  // 是否找到元素
  var fnd = false;
  var sub_display = img.src.indexOf('menu_minus.gif') > 0 ? 'none' : (Browser.isIE) ? 'block' : 'table-row' ;
  // 遍历所有的分类
  for (i = 0; i < tbl.rows.length; i++)
  {
      var row = tbl.rows[i];
      if (row == obj)
      {
          // 找到当前行
          fnd = true;
          //document.getElementById('result').innerHTML += 'Find row at ' + i +"<br/>";
      }
      else
      {
          if (fnd == true)
          {
              var cur = parseInt(row.className);
              var icon = 'icon_' + row.id;
              if (cur > lvl)
              {
                  row.style.display = sub_display;
                  if (sub_display != 'none')
                  {
                      var iconimg = document.getElementById(icon);
                      iconimg.src = iconimg.src.replace('plus.gif', 'minus.gif');
                  }
              }
              else
              {
                  fnd = false;
                  break;
              }
          }
      }
  }

  for (i = 0; i < obj.cells[0].childNodes.length; i++)
  {
      var imgObj = obj.cells[0].childNodes[i];
      if (imgObj.tagName == "IMG" && imgObj.src != '__PUBLIC__/Admin/images/menu_arrow.gif')
      {
          imgObj.src = (imgObj.src == imgPlus.src) ? '__PUBLIC__/Admin/images/menu_minus.gif' : imgPlus.src;
      }
  }
}
//--></script>

</body>
</html>